package com.wisdytech.common.bean;

import com.alibaba.fastjson.JSON;

import java.io.Serializable;

/**
 *
 * <p>ClassName: StandardResult</p>
 * <p>Description: 标准返回值</p>
 * <p>Author: dailibo</p>
 * <p>Date: 2017-9-16</p>
 */
public class StandardMsg implements Serializable {

    /**
     * <p>Field serialVersionUID: TODO</p>
     */
    private static final long serialVersionUID = 3512854729146995105L;
    /**code*/
    private String code;
    /**是否成功*/
    private boolean result;
    /**相关信息*/
    private String message;

    public StandardMsg(){

    }
    public StandardMsg(String code,boolean result){
        this.code=code;
        this.result = result;
    }

    public StandardMsg(String code,boolean result,String message){
        this.code=code;
        this.result = result;
        this.message=message;
    }

    public static String getFailResult(ResultEnum resultEnum){
        return JSON.toJSONString(
                new StandardMsg(resultEnum.getCode(),false,resultEnum.getMessage()));
    }

    public static String getSuccessResult(){
        return JSON.toJSONString(
                new StandardMsg(ResultEnum.SUCCESS.getCode(),true,ResultEnum.SUCCESS.getMessage()));
    }
    public static String getSuccessResult(ResultEnum resultEnum){
        return JSON.toJSONString(
                new StandardMsg(resultEnum.getCode(),true,resultEnum.getMessage()));
    }












    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public boolean isResult() {
        return result;
    }
    public void setResult(boolean result) {
        this.result = result;
    }
    public String getMessage() {
        return message;
    }
    public void setMessage(String message) {
        this.message = message;
    }




}
